<link rel="shortcut icon" href="../images/lfg-log.ico">
<?php
   //第一步：连接数据库
   require 'db_conn.php';//如果这个文件不存在，则程序终止
   //第二步：写查询语句并执行
   $p=isset($_GET['p'])?$_GET['p']:1;
   $size=10;
   $f=($p-1)*$size;
   if(isset($_GET['search'])){
	   $s=$_GET['search'];
	   $sqll="select * from t_message where message like '%{$s}%'";
	   $res=$db->query($sqll);
	   $sum=$res->num_rows;
	   $pnum=ceil($sum/$size);
	   $sql="select * from t_message where message like '%{$s}%' ORDER BY id desc limit $f,$size";
   }
   
   else{
	   
	   $sqll="select * from t_message";
	   $res=$db->query($sqll);
	   $sum=$res->num_rows;
	   $pnum=ceil($sum/$size);
	     $sql="select * from t_message ORDER BY id desc limit $f,$size";
   }
   
 
   $rs=$db->query($sql);
   //取结果集的行数，留言板表有多少条留言
   
   $bbs=$rs->fetch_all(MYSQLI_ASSOC);//将结果集转化为数组-关联数组，下标为字符串
   require 'html.php'
   // $rs->free_result();//结果集清楚
   // $db->close();//关闭数据库
?>
